import {Component, OnInit} from '@angular/core';
import {Observable} from "rxjs";
import {AuthService} from "../core/auth.service";

@Component({
  selector: 'oidc-app-app-menu',
  templateUrl: './app-menu.component.html',
  styleUrls: ['./app-menu.component.css']
})
export class AppMenuComponent implements OnInit {

  // 可以在这里定义菜单项的数据源
  menuItems = [
    { title: 'Admin-3 ngx_permissions应用', link: 'ngx_permissions/admin3' },
    { title: '关于我们', link: '/about' },
    { title: '联系我们', link: '/contact' }
  ];

  isAuthenticated$: Observable<boolean>;

  constructor(private authService: AuthService) {
    this.isAuthenticated$ = authService.isAuthenticated$;
  }

  login() {
    this.authService.login();  //'http://127.0.0.1:9000/login'
  }
  logout() {
    this.authService.logout();
  }

  get email(): string {
    return this.authService.identityClaims
      ? (this.authService.identityClaims as any)['email']
      : '-';
  }

  ngOnInit(): void {
  }

  isCollapsed = false;

}
